<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script src="./as.js"></script>
<script>
    // console.log(address);

    function dataSet(address){
    const data = address.filter(item => item.TopID == 0)
    // console.log(data);

    data.forEach(item => {
        item.children = []

        //添加市
        address.forEach(e => {
            if(item.ID == e.TopID){
                item.children.push(e)
            }
        })

        //市里面 添加 县

        item.children.forEach(city => {
            city.children = []

            address.forEach(i => {
                if(city.ID == i.TopID){
                    city.children.push(i)
                }
            })
        })

    })
    return data
}
console.log(dataSet(address));



</script>